package adsi.persistence;

import adsi.domain.*;
import java.util.*;

/**
 * DataServiceModel is the interface that defines the interfase to the 
 * DataService class. It defines methods to give persistence to the Equipment,
 * Line, Maintenance, EquipmentMaintenance and ProgrammedMaintenance classes.
 *
 */
public interface DataServiceModel {

    /**
     * Saves the Equipment object in the persistent medium. If there is already an
     * Equipment with the same Tail Number, the Equipment won't be saved and a
     * DataServiceException will be thrown.
     * <p>
     * This method returns the unique ID assigned to the object by the persistent 
     * medium. If a value of -1 is returned, it means the object was not stored.
     *
     * @param  e                    Equipment object to be stored.
     * @return                      the unique ID assigned by the persistent medium
     * @throws DataServiceException If a problem ocurrs when giving persistence to
     *                              the object.
     * @see                         DataServiceModel
     * @see                         Equipment
     */
    public long saveEquipment(Equipment e) throws DataServiceException;

    /**
     * Marks the stored Equipment object corresponding to the specified ID
     * as deleted in the persistent medium. 
     * <p>
     * When an Equipment is marked as deleted, all EquipmentMaintenance and 
     * ProgrammedMaintenance stored objects associated to it are also marked as
     * deleted.
     * <p>
     * If any ProgrammedMaintenance was marked as deleted, the optimization 
     * algorithm will be run automatically. This method does not call 
     * deleteProgrammedMaintenance but instead handles the marking as deleted for
     * the stored ProgrammedMaintenance objects directly to avoid running multiple 
     * times the optimization algorithm.
     *
     * @param  ID                   Unique ID of the Equipment object on the 
     *                              persistent medium.
     * @throws DataServiceException If a problem ocurrs when marking the stored 
     *                              object as deleted.
     * @see                         DataServiceModel
     */
    public void deleteEquipment(long ID) throws DataServiceException;

    /**
     * Removes the deletion mark from the object corresponding to the ID.
     *
     * @throws DataServiceException If a problem ocurrs when removing the deletion 
     *                              mark from the object on the persistent medium.
     * @see                         DataServiceModel
     */
    public void undeleteEquipment(long ID) throws DataServiceException;

    /**
     * Retrieves the Equipment object corresponding to the specified ID from the 
     * persistent medium. If the ID does not exist in the persisten medium, a 
     * DataServiceException is thrown.
     *
     * @param  ID                   Unique ID of the Equipment object stored in the 
     *                              persistent medium.
     * @return                      the Equipment object corresponing to the 
     *                              specifyed ID.
     * @throws DataServiceException If a problem ocurrs when recovering the object
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Equipment
     *                              object to return.
     * @see                         DataServiceModel
     */
    public Equipment retrieveEquipment(long ID) throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment object corresponding to the specified tailNumber from 
     * the persistent medium. If the Tail Number does not exist in the persisten 
     * medium, a DataServiceException is thrown.
     *
     * @param  tailNumber           Tail Number of the Equipment object stored in 
     *                              the persistent medium.
     * @return                      the Equipment object corresponing to the 
     *                              specifyed Tail Number.
     * @throws DataServiceException If a problem ocurrs when recovering the object
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Equipment
     *                              object to return.
     * @see                         DataServiceModel
     */
    public Equipment retrieveEquipment(String tailNumber) throws DataServiceException, EntityException;

    /**
     * Retrieves all the Equipment objects stored on the persistent medium. 
     *
     * @return                      A List containing all the Equipment 
     *                              objects stored on the persistent medium. 
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public List<Equipment> retrieveEquipments() throws DataServiceException, EntityException;

    /**
     * Retrieves the ID's and Tail Numbes of all the Equipment objects stored on 
     * the persistent medium. 
     *
     * @return                      A Map containing all the Equipment ID's as
     *                              the key and their corresponding Tail Numbers as
     *                              the String object asociated to the key.
     * @throws DataServiceException If a problem ocurrs when recovering the data
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public Map<Long, String> retrieveEquipmentsIDs() throws DataServiceException;

    /**
     * Retrieves the Equipment objects stored on the persistent medium whose 
     * Tail Number contain the description substring. 
     *
     * @param  description          A string that will be looked for in the Tail 
     *                              Number attribute of the stored objects to be
     *                              retrieved.
     * @return                      A List containing the Equipments whose Tail Number contains
     *                              the specifyed description substring.
     * @throws DataServiceException If a problem ocurrs when recovering the data
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public List<Equipment> retrieveEquipmentsLike(String description, String order);

    /**
     * Retrieves all the Equipment objects stored on the persistent medium which are
     * marked as delivered.
     *
     * @return                      A List containing all the Equipment 
     *                              objects stored on the persistent medium, which
     *                              are marked as delivered. 
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public List<Equipment> retrieveDeliveredEquipments() throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion        Crterion to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start                Calendar object which value indicates the start
     *                              of the range.
     * @param  end                  Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Equipment> retrieveEquipmentsInRange(Map<String, Object> searchParameters);

//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion, Calendar start, Calendar end)
//            throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion        Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start                Calendar object which value indicates the start
     *                              of the range.
     * @param  end                  Calendar object which value indicates the end
     *                              of the range.
     * @param  onlyDelivered        Boolean value indicating whether to constraint 
     *                              or not the search only to stored Equipment
     *                              objects marked as delevered.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion, Calendar start, Calendar end,
//            boolean onlyDelivered)
//            throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * parameters are on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>     Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
//            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2)
//            throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * parameters are on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>      Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @param  onlyDelivered        Boolean value indicating whether to constraint 
     *                              or not the search only to stored Equipment
     *                              objects marked as delevered.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
//            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
//            boolean onlyDelivered)
//            throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * parameters are on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>      Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
//            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
//            DataServiceSearchCriterias dateCriterion3, Calendar start3, Calendar end3)
//            throws DataServiceException, EntityException;

    /**
     * Retrieves the Equipment objects from the persistent medium which dateCriterion
     * parameters are on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>      Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES or 
     *                              DataServiceSearchCriterias.AVAILABLE_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @param  onlyDelivered        Boolean value indicating whether to constraint 
     *                              or not the search only to stored Equipment
     *                              objects marked as delevered.
     * @return                      A List containing all the Equipment 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
//    public List<Equipment> retrieveEquipmentsInRange(
//            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
//            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
//            DataServiceSearchCriterias dateCriterion3, Calendar start3, Calendar end3,
//            boolean onlyDelivered)
//            throws DataServiceException, EntityException;

    /**
     * Saves the Line object in the persistent medium. 
     * <p>
     * This method returns the unique ID assigned to the object by the persistent 
     * medium. If a value of -1 is returned, it means the object was not stored.
     * <p>
     * Every time a Line object is saved, the optimization algorithm will be 
     * run automatically.
     *
     * @param  l                    Line object to be stored.
     * @return                      The unique ID assigned by the persistent medium
     * @throws DataServiceException If a problem ocurrs when giving persistence to
     *                              the object.
     * @see                         DataServiceModel
     * @see                         Line
     */
    public long saveLine(Line l) throws DataServiceException;

    /**
     * Marks the stored Line object corresponding to the specified ID
     * as deleted in the persistent medium. 
     * <p>
     * Line object can be marked as deleted only if it is not currently assigned to 
     * any ProgrammedMaintenance object (in the persistent medium). If it is 
     * currently assigned to a ProgrammedMaintenance object, an automatic attempt to
     * reasign other lines to the ProgrammedMaintenance objects will be made by 
     * running the optimization algoritm and the Line object will be marked as 
     * deleted only if full reasignation is achieved.
     *
     * @param  ID                   Unique ID of the Line object on the 
     *                              persistent medium.
     * @throws DataServiceException If a problem ocurrs when marking the stored 
     *                              object as deleted.
     * @see                         DataServiceModel
     */
    public void deleteLine(long ID) throws DataServiceException;

    /**
     * Removes the deletion mark from the object corresponding to the ID.
     *
     * @throws DataServiceException If a problem ocurrs when removing the deletion 
     *                              mark from the object on the persistent medium.
     * @see                         DataServiceModel
     */
    public void undeleteLine(long ID) throws DataServiceException;

    /**
     * Retrieves the Line object corresponding to the specified ID from the 
     * persistent medium. If the ID does not exist in the persisten medium, a 
     * DataServiceException is thrown.
     *
     * @param  ID                   Unique ID of the Line object stored in the 
     *                              persistent medium.
     * @return                      the Line object corresponing to the 
     *                              specifyed ID.
     * @throws DataServiceException If a problem ocurrs when recovering the object
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Line
     *                              object to return.
     * @see                         DataServiceModel
     */
    public Line retrieveLine(int ID) throws DataServiceException, EntityException;

    /**
     * Retrieves all the Line objects stored on the persistent medium. 
     *
     * @return                      A List containing all the Line 
     *                              objects stored on the persistent medium. 
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public List<Line> retrieveLines() throws DataServiceException, EntityException;

    /**
     * Retrieves the ID's and descriptions of all the Line objects stored on 
     * the persistent medium. 
     *
     * @return                      A Map containing all the Line ID's as
     *                              the key and their corresponding descriptions as
     *                              the String object asociated to the key.
     * @throws DataServiceException If a problem ocurrs when recovering the data
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public Map<Long, String> retrieveLinesIDs() throws DataServiceException;

    /**
     * Retrieves the ID's and descriptions of the Line objects stored on 
     * the persistent medium whose description contains the description substring. 
     *
     * @param  description          A string that will be looked for in the  
     *                              description attribute of the stored objects to 
     *                              be retrieved.
     * @return                      A Map containing the Line ID's as
     *                              the key and their corresponding Line objects as
     *                              the object asociated to the key for the 
     *                              stored objects whose description contains the
     *                              specifyed description substring.
     * @throws DataServiceException If a problem ocurrs when recovering the data
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public Map<Long, Line> retrieveLinesLike(String description) throws DataServiceException, EntityException;

    /**
     * Retrieves the Line objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion        Crterion to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES,
     *                              DataServiceSearchCriterias.AVAILABLE_DATES,
     *                              DataServiceSearchCriterias.FREE_DATES or
     *                              DataServiceSearchCriterias.BUSY_DATES
     * @param  start                Calendar object which value indicates the start
     *                              of the range.
     * @param  end                  Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Line 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Line> retrieveLinesInRange(
            DataServiceSearchCriterias dateCriterion, Calendar start, Calendar end)
            throws DataServiceException, EntityException;

    /**
     * Retrieves the Line objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>     Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES,
     *                              DataServiceSearchCriterias.AVAILABLE_DATES,
     *                              DataServiceSearchCriterias.FREE_DATES or
     *                              DataServiceSearchCriterias.BUSY_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Line 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Line> retrieveLinesInRange(
            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2)
            throws DataServiceException, EntityException;

    /**
     * Retrieves the Line objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>     Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES,
     *                              DataServiceSearchCriterias.AVAILABLE_DATES,
     *                              DataServiceSearchCriterias.FREE_DATES or
     *                              DataServiceSearchCriterias.BUSY_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Line 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Line> retrieveLinesInRange(
            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
            DataServiceSearchCriterias dateCriterion3, Calendar start3, Calendar end3)
            throws DataServiceException, EntityException;

    /**
     * Retrieves the Line objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>     Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES,
     *                              DataServiceSearchCriterias.AVAILABLE_DATES,
     *                              DataServiceSearchCriterias.FREE_DATES or
     *                              DataServiceSearchCriterias.BUSY_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Line 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Line> retrieveLinesInRange(
            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
            DataServiceSearchCriterias dateCriterion3, Calendar start3, Calendar end3,
            DataServiceSearchCriterias dateCriterion4, Calendar start4, Calendar end4)
            throws DataServiceException, EntityException;

    /**
     * Retrieves the Line objects from the persistent medium which dateCriterion
     * is on the specified range. It's possible to specify only one, 
     * various or all the possible dateCriterion options.
     *
     * @param  dateCriterion<n>     Crteria to which the range will be applied. It
     *                              must be DataServiceSearchCriterias.CREATION_DATES,
     *                              DataServiceSearchCriterias.DELETION_DATES,
     *                              DataServiceSearchCriterias.AVAILABLE_DATES,
     *                              DataServiceSearchCriterias.FREE_DATES or
     *                              DataServiceSearchCriterias.BUSY_DATES
     * @param  start<n>             Calendar object which value indicates the start
     *                              of the range.
     * @param  end<n>               Calendar object which value indicates the end
     *                              of the range.
     * @return                      A List containing all the Line 
     *                              objects which commit to the search criteria.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     * @see                         DataServiceSearchCriterias
     * @see                         Calendar
     */
    public List<Line> retrieveLinesInRange(
            DataServiceSearchCriterias dateCriterion1, Calendar start1, Calendar end1,
            DataServiceSearchCriterias dateCriterion2, Calendar start2, Calendar end2,
            DataServiceSearchCriterias dateCriterion3, Calendar start3, Calendar end3,
            DataServiceSearchCriterias dateCriterion4, Calendar start4, Calendar end4,
            DataServiceSearchCriterias dateCriterion5, Calendar start5, Calendar end5)
            throws DataServiceException, EntityException;

    /**
     * Saves the EquipmentMaintenance object in the persistent medium.
     * <p>
     * This method returns the unique ID assigned to the object by the persistent 
     * medium. If a value of -1 is returned, it means the object was not stored.
     *
     * @param  em                   EquipmentMaintenance object to be stored.
     * @return                      the unique ID assigned by the persistent medium
     * @throws DataServiceException If a problem ocurrs when giving persistence to
     *                              the object.
     * @see                         DataServiceModel
     * @see                         EquipmentMaintenance
     */
    public long saveEquipmentMaintenance(EquipmentMaintenance em) throws DataServiceException;

    /**
     * Marks the stored EquipmentMaintenance object corresponding to the specified 
     * ID as deleted in the persistent medium. 
     * <p>
     * EquipmentMaintenance object can be marked as deleted only if it is not  
     * currently referenced from any ProgrammedMaintenance object (in the persistent 
     * medium). If there are objects marked as deleted that reference the 
     * EquipmentMaintenance object being deleted, deletion can not be performed, in 
     * which case executing a call to the purge method of the corresponding
     * DataServiceModel instance might enable the marking of the object as deleted. 
     *
     * @param  ID                   Unique ID of the EquipmentMaintenance object on  
     *                              the persistent medium.
     * @throws DataServiceException If a problem ocurrs when marking the stored 
     *                              object as deleted.
     * @see                         DataServiceModel
     */
    public void deleteEquipmentMaintenance(long ID) throws DataServiceException;

    /**
     * Removes the deletion mark from the object corresponding to the ID.
     *
     * @throws DataServiceException If a problem ocurrs when removing the deletion 
     *                              mark from the object on the persistent medium.
     * @see                         DataServiceModel
     */
    public void undeleteEquipmentMaintenance(long ID) throws DataServiceException;

    /**
     * Retrieves the EquipmentMaintenance object corresponding to the specified ID 
     * from the persistent medium. If the ID does not exist in the persisten medium,
     * a DataServiceException is thrown.
     *
     * @param  ID                   Unique ID of the EquipmentMaintenance object 
     *                              stored in the persistent medium.
     * @return                      the EquipmentMaintenance object corresponing to 
     *                              the specifyed ID.
     * @throws DataServiceException If a problem ocurrs when recovering the object
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the 
     *                              EquipmentMaintenance object to return.
     * @see                         DataServiceModel
     */
    public EquipmentMaintenance retrieveEquipmentMaintenance(long ID) throws DataServiceException, EntityException;

    /**
     * Retrieves the EquipmentMaintenance objects stored on the persistent medium 
     * corresponding to the specified equipmentID.
     *
     * @param  ID                   Unique ID of the Equipment object for which 
     *                              EquipmentMaintenance objects will be returned.
     * @return                      A List containing all the EquipmentMaintenance 
     *                              objects stored on the persistent medium that
     *                              correspond to the Equipment whose unique ID is
     *                              equipmentID.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public List<EquipmentMaintenance> retrieveEquipmentLog(long equipmentID) throws DataServiceException, EntityException;

    /**
     * Retrieves all the EquipmentMaintenance objects stored on the persistent medium.
     *
     * @return                      A Map containing all the EquipmentMaintenance 
     *                              objects as Lists associated with it's 
     *                              corresponding Equipment object of which ID
     *                              is used as the key for the list in the Hash. 
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public Map<Long, List<EquipmentMaintenance>> retrieveLog() throws DataServiceException, EntityException;

    /**
     * Saves the ProgrammedMaintenance object in the persistent medium.
     * <p>
     * This method returns the unique ID assigned to the object by the persistent 
     * medium. If a value of -1 is returned, it means the object was not stored.
     *
     * @param  pm                   ProgrammedMaintenance object to be stored.
     * @return                      the unique ID assigned by the persistent medium
     * @throws DataServiceException If a problem ocurrs when giving persistence to
     *                              the object.
     * @see                         DataServiceModel
     * @see                         ProgrammedMaintenance
     */
    public long saveProgrammedMaintenance(ProgrammedMaintenance pm) throws DataServiceException;

    /**
     * Marks the stored ProgrammedMaintenance object corresponding to the specified 
     * ID as deleted in the persistent medium. 
     *
     * @param  ID                   Unique ID of the ProgrammedMaintenance object on  
     *                              the persistent medium.
     * @throws DataServiceException If a problem ocurrs when marking the stored 
     *                              object as deleted.
     * @see                         DataServiceModel
     */
    public void deleteProgrammedMaintenance(long ID) throws DataServiceException;

    /**
     * Removes the deletion mark from the object corresponding to the ID.
     *
     * @throws DataServiceException If a problem ocurrs when removing the deletion 
     *                              mark from the object on the persistent medium.
     * @see                         DataServiceModel
     */
    public void undeleteProgrammedMaintenance(long ID) throws DataServiceException;

    /**
     * Retrieves the ProgrammedMaintenance object corresponding to the specified ID 
     * from the persistent medium. If the ID does not exist in the persisten medium,
     * a DataServiceException is thrown.
     *
     * @param  ID                   Unique ID of the ProgrammedMaintenance object 
     *                              stored in the persistent medium.
     * @return                      the ProgrammedMaintenance object corresponing to 
     *                              the specifyed ID.
     * @throws DataServiceException If a problem ocurrs when recovering the object
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the 
     *                              ProgramedMaintenance object to return.
     * @see                         DataServiceModel
     */
    public ProgrammedMaintenance retrieveProgrammedMaintenance(long ID) throws DataServiceException, EntityException;

    /**
     * Retrieves the ProgrammedMaintenance objects stored on the persistent medium 
     * corresponding to the specified equipmentID.
     *
     * @param  ID                   Unique ID of the Equipment object for which 
     *                              ProgrammedMaintenance objects will be returned.
     * @return                      A List containing all the ProgrammedMaintenance 
     *                              objects stored on the persistent medium that
     *                              correspond to the Equipment whose unique ID is
     *                              equipmentID.
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public List<ProgrammedMaintenance> retrieveEquipmentProgram(long equipmentID) throws DataServiceException, EntityException;

    /**
     * Retrieves all the ProgrammedMaintenance objects stored on the persistent medium.
     *
     * @return                      A Map containing all the ProgrammedMaintenance 
     *                              objects as Lists associated with it's 
     *                              corresponding Equipment object of which ID
     *                              is used as the key for the list in the Hash. 
     * @throws DataServiceException If a problem ocurrs when recovering the objects
     *                              from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    public Map<Long, List<ProgrammedMaintenance>> retrieveProgram() throws DataServiceException, EntityException;

    /**
     * Removes permanently all the ProgrammedMaintenance objects.
     *
     * @throws DataServiceException If a problem ocurrs when removing the objects
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public void deleteAllPrograms() throws DataServiceException;

    /**
     * Removes permanently all the objects marked as deleted.
     *
     * @throws DataServiceException If a problem ocurrs when removing the objects
     *                              from the persistent medium.
     * @see                         DataServiceModel
     */
    public void purge();

    /**
     * Retrieves the objects that are marked as deleted that are of the same class
     * as the sample object.
     *
     * @return                      A List containing all the objects 
     *                              stored on the persistent medium that are markd
     *                              as deleted. 
     * @throws DataServiceException If the sample object does not correspond to the 
     *                              class of a valid object marked as deleted or if 
     *                              any other problem ocurrs when recovering the 
     *                              objects from the persistent medium.
     * @throws EntityException      If there where errors when creating the Elements
     *                              for the List.
     * @see                         DataServiceModel
     */
    //HAY QUE REVISAR LA SINTAXIS DE GENERICS DEL SIGUIENTE MÉTODO!!!
    public List<?> retrieveDeletedObjects(Object sample) throws DataServiceException, EntityException;
}
